//
//  YSPrizeInfoView.m
//  Yaoyle
//
//  Created by ZhaoXudong on 14-10-16.
//  Copyright (c) 2014年 ZhaoXudong. All rights reserved.
//

#import "YSPrizeInfoView.h"
#import "UIViewExt.h"
#import "YSUtility.h"

@interface YSPrizeInfoView () {
    UIImageView *iconView;
    UILabel *titleLabel;
}

@end

@implementation YSPrizeInfoView

- (id)initWithPoint:(CGPoint)point
{
    self = [super initWithFrame:CGRectMake(point.x, point.y, 80, 80)];
    if (self) {
        // Initialization code
        UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
        bgView.image = [UIImage imageNamed:@"prize_bg"];
        [self addSubview:bgView];
        [self sendSubviewToBack:bgView];

        iconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 45)];
        iconView.image = [UIImage imageNamed:@"raffle_query"];
        [self addSubview:iconView];
        
        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, iconView.bottom + 2, 80, 15)];
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.font = [UIFont systemFontOfSize:13];
        titleLabel.text = @"神秘大奖";
        [self addSubview:titleLabel];
    }
    return self;
}

- (void)setPrizeModel:(YSPrizeModel *)model {
    if (![YSUtility isBlankObject:model.prizePhoto]) {
        NSURL *url = [[NSURL alloc] initWithString:model.prizePhoto];
        UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
        
        iconView.image = image;
    }
    
    if (![YSUtility isBlankObject:model.prizeName]) {
        titleLabel.text = model.prizeName;
    }
    
}

@end
